package com.qfedu.edu.seckill.classservice.controller;


import com.qfedu.edu.seckill.classservice.feign.api.StockStorageService;
import com.qfedu.edu.seckill.classservice.service.ClassService;
import com.qfedu.edu.seckill.po.Class;
import com.qfedu.edu.seckill.result.R;
import com.qfedu.edu.seckill.vo.AddClassVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author xiaobobo
 * @since 2025-01-13
 */
@RestController
@RequestMapping("/classservice/class")
public class ClassController {

    @Autowired
    private ClassService classService;

    @Autowired
    private StockStorageService stockStorageService;

    @GetMapping("list")
    public R list(){
        List<Class> list = classService.list(null);
        return R.ok().data("classList",list);
    }

    /**
     * 查询所有的库存信息
     * @return
     */
    @GetMapping("listStorage")
    public R listStorage(){
        R r = stockStorageService.list();
        return r;
    }

    /**
     * 添加秒杀商品
     * @param addClassVo
     * @param file
     * @return
     */
    @PostMapping("addClass")
    public  R addClass(AddClassVo addClassVo, MultipartFile file) throws Exception {
        classService.addClass(addClassVo,file);
        return  R.ok();
    }




}

